package Cluster;

class QEle {
	public Trajectory traj1 = null, traj2 = null;
	public ClusterBulk cluster1 = null, cluster2 = null;
	public double dist = 0.0;
	public int type = 0;
	
	public QEle(Trajectory traj1, Trajectory traj2, double dist) {
		this.traj1 = traj1;
		this.traj2 = traj2;
		if(this.traj1.GET003_trajID() > this.traj2.GET003_trajID()) {
			Trajectory temp = this.traj1;
			this.traj1 = this.traj2;
			this.traj2 = temp;
		}
		this.dist = dist;
		this.type = 0;
		//this.ACT003_show();
	}
	
	public boolean ACT001_checkEqual(QEle getE) {
		boolean isEqual = false;
		if(this.type == getE.type) {
			switch(type) {
			case 0 :
				if(this.traj1.traj_id == getE.traj1.traj_id && 
					this.traj2.traj_id == getE.traj2.traj_id) {
					isEqual = true;
				}
				break;
			case 1 :
				if(this.cluster1.GET005_id() == getE.cluster1.GET005_id() &&
						this.traj2.traj_id == getE.traj2.traj_id) {
					isEqual = true;
				}
				break;
			case 2 :
				if(this.cluster1.GET005_id() == getE.cluster1.GET005_id() &&
						this.cluster2.GET005_id() == getE.cluster2.GET005_id()){
					isEqual = true;
				}
				break;
			}
		}
		return isEqual;
	}
	
	public boolean ACT002_hasEqual(Trajectory traj) {
		return (this.traj1 != null && traj.traj_id == this.traj1.traj_id) || 
				(this.traj2 != null && traj.traj_id == this.traj2.traj_id);
	}
	
	public boolean ACT002_hasEqual(ClusterBulk cluster) {
		return (this.cluster1 != null && cluster.clusterID == this.cluster1.clusterID) ||
				(this.cluster2 != null && cluster.clusterID == this.cluster2.clusterID);
	}
	
    public void ACT003_show() {
    	if(this.traj1 != null) {
    		System.out.print("Traj" + this.traj1.GET003_trajID() + "||");
    	}
    	if(this.cluster1 != null) {
    		System.out.print("Cluster " + this.cluster1.GET002_listTraj().size() + "||");
    	}
    	if(this.traj2 != null) {
    		System.out.print("Traj" + this.traj2.GET003_trajID() + "||");
    	}
    	if(this.cluster2 != null) {
    		System.out.print("Cluster " + this.cluster2.GET002_listTraj().size() + "||");
    	}
    	System.out.println("Dist=" + this.dist);
    }
}
